package com.list;

import java.io.File;
import java.io.IOException;
import android.app.Activity;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Comparacion extends Activity {
	MediaRecorder recorder = null;
	File archivo;
	final String LOG_TAG = "log";
	TextView salida;
	Button grabar,parar,imprimir;
	

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d("CalledActivity","OnCreate ");
        setContentView(R.layout.compraracion); 
        
        grabar =(Button)findViewById(R.id.grabar);
	    parar =(Button)findViewById(R.id.parar);
	}
	
	public void grabar(View v) {
		parar.setEnabled(false);
		recorder = new MediaRecorder();
		recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
		//recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		File path = new File(Environment.getExternalStorageDirectory().getPath());	
		try {
			archivo = File.createTempFile("temporal", ".3gp", path);
		} catch (IOException e) {
		}	
		recorder.setOutputFile(archivo.getAbsolutePath());
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		try {
            recorder.prepare();
        } catch (IOException e) {
            Log.e(LOG_TAG, "prepare() failed");
        }
        recorder.start();
        grabar.setEnabled(false);
        parar.setEnabled(true);
        
	}
	
	public void detener(View v) {
		recorder.stop();
		recorder.release();	
        recorder = null;
        grabar.setEnabled(true);
        parar.setEnabled(false);
	}
	

}
